<!--布局组件，这个组件可以在app.vue中引入-->
<template>

  <div style="height: 50px; line-height: 50px; border-bottom: 1px solid #ccc; display: flex">
    <!--display: flex 布局就是将盒状的元素变成行内的来使用-->
    <div style="width: 200px; padding-left: 30px; font-weight: bold; color: dodgerblue">后台管理</div>
    <div style="flex: 1"></div>

<!--    引入下拉菜单-->
    <div style="width: 100px; padding-top: 15px;">
      <el-dropdown>
        <span class="el-dropdown-link">
          {{user?.nickName}}
        <el-icon class="el-icon--right">
          <arrow-down/>
        </el-icon>
      </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="ToPerson">个人信息</el-dropdown-item>
            <el-dropdown-item @click="loginOut">退出系统</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import router from "@/router";
export default {
  name: "Header",
  data() {
    return {
      user: JSON.parse(sessionStorage.getItem("user"))
    }
  },
  methods: {
    //退出系统
    loginOut() {
      sessionStorage.removeItem("user")
      router.push("/login")
    },

    //前往个人信息
    ToPerson() {
      router.push("/person")
    },

  },
}
</script>

<style scoped>

</style>